﻿<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucManageStaff.ascx.vb" Inherits="RWN.ucManageStaff" %>
<%@ Register Assembly="NumericTextBox" Namespace="NumericTextBoxControl" TagPrefix="cc1" %>
<%@ Register Assembly="Sarayut.ControlLibrary" Namespace="Sarayut.ControlLibrary" TagPrefix="cc2" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc3" %>
<%@ Register Assembly="AjaxValidationSummary" Namespace="AjaxValidationSummary" TagPrefix="cc4" %>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True">
</asp:ScriptManager>
<asp:Literal ID="ltrJS" runat="server"></asp:Literal>
<script language="JavaScript">

    var cardIDExp = document.getElementById("<%=OFFICER_CARD_EXPIREDATE.ClientID%>");

	function checkID(id) {
		if (id.length != 13) return false;
		for (i = 0, sum = 0; i < 12; i++)
			sum += parseFloat(id.charAt(i)) * (13 - i); if ((11 - sum % 11) % 10 != parseFloat(id.charAt(12)))
			return false; return true;
	}

	function checkIDCard(sender, args) {
	    var ddlCardType = document.getElementById("<%=ddlCardType.ClientID%>");
	    var CardType = ddlCardType.options[ddlCardType.selectedIndex].value;
	    var val = document.getElementById(cardID).value.replace('-', '');

		if (CardType != "PID") {
		    args.IsValid = true;
			return;
        }

		if (val.length != 13) {
		    args.IsValid = false;
			return;
		}

		if (checkID(val)) {
			args.IsValid = true;
			return;
		} else {
			args.IsValid = false;
			return;
		}
	}

	function ChangFormatID() {
		var val = document.getElementById(appID).value.replace('-', '');
		if (val.length != 10) {
			return;
		}
		document.getElementById(appID).value = val.substr(0, 2) + '-' + val.substr(2, 8);
	}

	function ValidateID(sender, args) {

		var val = document.getElementById(appID).value.replace('-', '');

		if (val == "") {
			args.IsValid = false;
			return;
		}

		if (val.length != 10) {
			args.IsValid = false;
			return;
		}

		document.getElementById(appID).value = val.substr(0, 2) + '-' + val.substr(2, 8);
		args.IsValid = true;
	}

	function ValidateBirthDate(sender, args) {

	    if (document.getElementById(brithdayID).value == "") {
	        args.IsValid = false;
	        return;
	    }
	    args.IsValid = true;
	}

	function ValidateCardDate(sender, args) {
	    if (document.getElementById(carddayID).value == "" && document.getElementById("ctl00_ContentPlaceHolder1_ucManageStaff_OFFICER_CARD_EXPIREDATE_TYPE_0").checked == true) {
	        args.IsValid = false;
	        return;
	    }
	    args.IsValid = true;
	}

	function ValidateCardTypeDesc(sender, args) {
	    var ddlCardType = document.getElementById("<%=ddlCardType.ClientID%>");
	    var CardType = ddlCardType.options[ddlCardType.selectedIndex].value;

	    if (CardType == "OTH") {
	        if (document.getElementById(cardTypeDesc).value == "") {
	            args.IsValid = false;
	            return;
	        }
	    }

	    args.IsValid = true;
	}

</script>
<table cellpadding="0" cellspacing="0" class="profile" style="width: 100%;" bgcolor="#FFFFFF">
	<tr>
		<td colspan="4" class="pk">
			<strong>
				<asp:Literal ID="ltrHeader" runat="server">เปลี่ยนแปลงแก้ไขข้อมูล</asp:Literal></strong>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0" width="20%">
			เลขที่เข้าใช้งาน *:
		</td>
		<td>
			<asp:TextBox ID="OFFICER_APP_ID" runat="server" MaxLength="255"></asp:TextBox>
			<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="OFFICER_APP_ID"
				ErrorMessage="กรุณาระบุเลขที่เข้าใช้งาน" ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0" width="20%">
			ชื่อ (ไทย) *:
		</td>
		<td>
			<asp:TextBox ID="OFFICER_FIRSTNAME_THA" runat="server" MaxLength="255" Width="200px"></asp:TextBox>
			<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="OFFICER_FIRSTNAME_THA"
				ErrorMessage="กรุณาระบุชื่อ (ไทย)" ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
		</td>
		<td bgcolor="#E0E0E0" width="20%">
			นามสกุล (ไทย) *:
		</td>
		<td>
			<asp:TextBox ID="OFFICER_LASTNAME_THA" runat="server" MaxLength="255" Width="200px"></asp:TextBox>
			<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="OFFICER_LASTNAME_THA"
				ErrorMessage="กรุณาระบุนามสกุล (ไทย)" ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0" width="20%">
			Name :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_FIRSTNAME_ENG" runat="server" MaxLength="255" Width="200px"></asp:TextBox>
		</td>
		<td bgcolor="#E0E0E0">
			Surname :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_LASTNAME_ENG" runat="server" MaxLength="255" 
                Width="200px"></asp:TextBox>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0" width="20%">
			เพศ:
		</td>
		<td>
			<asp:RadioButtonList ID="OFFICER_SEX" runat="server" RepeatDirection="Horizontal"
				RepeatLayout="Flow">
				<asp:ListItem Value="M">ชาย</asp:ListItem>
				<asp:ListItem Value="F">หญิง</asp:ListItem>
			</asp:RadioButtonList>
						<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" 
							ControlToValidate="OFFICER_SEX" ErrorMessage="กรุณาระบุเพศ" 
							ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0" width="20%">
			ประเภทบัตร: </td>
		<td>

			<asp:DropDownList ID="ddlCardType" runat="server" AutoPostBack="True">
				<asp:ListItem Value="PID" Selected="True">บัตรประชาชน</asp:ListItem>
				<asp:ListItem Value="CID">บัตรนิติบุคคล</asp:ListItem>
                <asp:ListItem Value="FID">บัตรคนต่างชาติ</asp:ListItem>
                <asp:ListItem Value="OTH">บัตรอื่นๆ</asp:ListItem>
			</asp:DropDownList>

		</td>
		<td bgcolor="#E0E0E0" >
			กรณีเลือกประเภทบัตรอื่นๆ<br />
            กรุณาระบุชนิดของบัตร:</td>
		<td>


			<asp:TextBox ID="OFFICER_CARD_TYPE_DESC" runat="server" MaxLength="255" 
                Width="200px" Enabled="False"></asp:TextBox>
		    <asp:CustomValidator ID="cvOfficerCardTypeDesc" runat="server" ErrorMessage="กรุณาระบุชนิดของบัตร"
			    ClientValidationFunction="ValidateCardTypeDesc" ValidationGroup="Reg1" Display="Dynamic">*</asp:CustomValidator>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0" width="20%">
			<asp:Label ID="lblCardType" runat="server" Text="เลขที่บัตรประชาชน *:"></asp:Label>
		</td>
		<td>
			<asp:TextBox ID="OFFICER_CARD_NO" runat="server" MaxLength="16" Width="200px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="OFFICER_CARD_NO"
				ErrorMessage="กรุณาระบุเลขที่บัตรประชาชน/นิติบุคคล/คนต่างชาติ/อื่นๆ" ValidationGroup="Reg1" Display="Dynamic">*</asp:RequiredFieldValidator>
            <%-- ErrorMessage="กรุณาระบุเลขที่บัตรประชาชน"
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="OFFICER_CARD_NO"
				Display="Dynamic" ErrorMessage="เลขที่บัตรประชาชนไม่ถูกต้อง" ValidationExpression="[0-9]{13,}"
				ValidationGroup="Reg1">*</asp:RegularExpressionValidator>--%>
			<asp:CustomValidator ID="CustomValidator4" runat="server" ClientValidationFunction="checkIDCard"
				ControlToValidate="OFFICER_CARD_NO" Display="Dynamic" ErrorMessage="เลขที่บัตรประชาชนไม่ถูกต้อง"
				ValidationGroup="Reg1">*</asp:CustomValidator>
		</td>
		<td bgcolor="#E0E0E0">
			วันเกิดตามบัตร *:
		</td>
		<td>
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td>
		                <asp:TextBox ID="OFFICER_BIRTHDATE" runat="server" Width="70px"></asp:TextBox><asp:ImageButton ID="ibtnOFFICER_BIRTHDATE" runat="server" ImageUrl="~/images/Calendar.gif" />
			            <cc3:CalendarExtender ID="OFFICER_BIRTHDATE_CalendarExtender" runat="server" 
				            CssClass="rnwCSS" Enabled="True" Format="dd/MM/yyyy" 
				            PopupButtonID="ibtnOFFICER_BIRTHDATE" TargetControlID="OFFICER_BIRTHDATE">
	                    </cc3:CalendarExtender>			
			             <asp:RegularExpressionValidator ID="revOfficerBirthdate" runat="server" 
                            ControlToValidate="OFFICER_BIRTHDATE" ErrorMessage="ท่านระบุรูปแบบวันที่ไม่ถูกต้อง (วว/ดด/ปปปป)" 
                            ValidationExpression="^\d{2}\/\d{2}\/\d{4}$" ValidationGroup="Reg1" 
				                Display="Dynamic">*</asp:RegularExpressionValidator>
		                <asp:RequiredFieldValidator
			                ID="rfvOfficerBirthdate" runat="server" ErrorMessage="กรุณาระบุวันเกิดตามบัตร"
			                ClientValidationFunction="ValidateBirthDate" ValidationGroup="Reg1" 
				            ControlToValidate="OFFICER_BIRTHDATE" Display="Dynamic">*</asp:RequiredFieldValidator>
				            <span class="tooltip_label">วัน/เดือน/ปีพ.ศ. เช่น 01/01/2500</span>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0" width="20%">
			บัตรหมดอายุ:
		</td>
		<td>
			<asp:RadioButtonList ID="OFFICER_CARD_EXPIREDATE_TYPE" runat="server" RepeatDirection="Horizontal"
				RepeatLayout="Flow">
				<asp:ListItem Value="Y">มีวันหมดอายุ</asp:ListItem>
				<asp:ListItem Value="N">ตลอดชีพ</asp:ListItem>
			</asp:RadioButtonList>
						<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" 
							ControlToValidate="OFFICER_CARD_EXPIREDATE_TYPE" ErrorMessage="กรุณาระบุชนิดบัตร"
							ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
		</td>
		<td bgcolor="#E0E0E0">
			วันบัตรหมดอายุ :
		</td>
		<td>
			<table cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td>
                        <asp:TextBox ID="OFFICER_CARD_EXPIREDATE" runat="server" Width="70px"></asp:TextBox><asp:ImageButton ID="ibtnOFFICER_CARD_EXPIREDATE" runat="server" ImageUrl="~/images/Calendar.gif" />
			            <cc3:CalendarExtender ID="CalendarExtender1" runat="server" 
				            CssClass="rnwCSS" Enabled="True" Format="dd/MM/yyyy" 
				            PopupButtonID="ibtnOFFICER_CARD_EXPIREDATE" TargetControlID="OFFICER_CARD_EXPIREDATE">
			            </cc3:CalendarExtender>			
			             <asp:RegularExpressionValidator ID="revOfficerCardExpiredate" runat="server" 
                            ControlToValidate="OFFICER_CARD_EXPIREDATE" ErrorMessage="ท่านระบุรูปแบบวันที่ไม่ถูกต้อง (วว/ดด/ปปปป)" 
                            ValidationExpression="^\d{2}\/\d{2}\/\d{4}$" ValidationGroup="Reg1" 
				            Display="Dynamic">*</asp:RegularExpressionValidator>
		                <asp:CustomValidator ID="cvOfficerCardExpiredate" runat="server" ErrorMessage="กรุณาระบุวันบัตรหมดอายุ"
			                ClientValidationFunction="ValidateCardDate" ValidationGroup="Reg1" Display="Dynamic">*</asp:CustomValidator>
			                <span class="tooltip_label">วัน/เดือน/ปีพ.ศ. เช่น 01/01/2500</span>
					</td>
				</tr>
			</table>        
        </td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0" width="20%">
			สถานะภาพ:
		</td>
		<td>
			<asp:RadioButtonList ID="OFFICER_MARRIED_STATUS" runat="server" RepeatDirection="Horizontal"
				RepeatLayout="Flow">
				<asp:ListItem Value="S">โสด</asp:ListItem>
				<asp:ListItem Value="M">สมรส</asp:ListItem>
			</asp:RadioButtonList>
						<asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server" 
							ControlToValidate="OFFICER_MARRIED_STATUS" ErrorMessage="กรุณาระบุสถานะภาพ" 
							ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
		</td>
		<td>
			&nbsp;</td>
		<td>
			&nbsp;</td>
	</tr>
	<tr>
		<td colspan="4">
			<hr />
		</td>
	</tr>
	<tr>
		<td colspan="4" class="pk">
			<strong>ที่อยู่ตามบัตรประชาชน</strong>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			เลขที่ :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_CARD_ADDRESS_NO" runat="server"></asp:TextBox>
		</td>
		<td bgcolor="#E0E0E0">
			หมู่ :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_CARD_ADDRESS_MOO" runat="server"></asp:TextBox>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			หมู่บ้าน/อาคาร :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_CARD_ADDRESS_BUILDING" runat="server"></asp:TextBox>
		</td>
		<td bgcolor="#E0E0E0">
			ซอย :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_CARD_ADDRESS_SOI" runat="server"></asp:TextBox>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			ถนน :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_CARD_ADDRESS_STREET" runat="server"></asp:TextBox>
		</td>
		<td bgcolor="#E0E0E0">
			จังหวัด *:
		</td>
		<td>
			<asp:DropDownList ID="OFFICER_CARD_ADDRESS_PROVINCE" runat="server" AutoPostBack="True">
			</asp:DropDownList>
			<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="OFFICER_CARD_ADDRESS_PROVINCE"
				ErrorMessage="กรุณาระบุจังหวัด" InitialValue="0" ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			เขต/อำเภอ *:
		</td>
		<td>
			<asp:UpdatePanel ID="UpdatePanel1" runat="server">
				<ContentTemplate>
					<asp:DropDownList ID="OFFICER_CARD_ADDRESS_DISTRICT" runat="server" AutoPostBack="True">
					</asp:DropDownList>
					<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="OFFICER_CARD_ADDRESS_DISTRICT"
						ErrorMessage="กรุณาระบุเขต/อำเภอ" InitialValue="0" ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
				</ContentTemplate>
				<Triggers>
					<asp:AsyncPostBackTrigger ControlID="OFFICER_CARD_ADDRESS_PROVINCE" EventName="SelectedIndexChanged" />
				</Triggers>
			</asp:UpdatePanel>
		</td>
		<td bgcolor="#E0E0E0">
			แขวง/ตำบล *:
		</td>
		<td>
			<asp:UpdatePanel ID="UpdatePanel2" runat="server">
				<ContentTemplate>
					<asp:DropDownList ID="officer_card_address_subICT" runat="server" AutoPostBack="True">
					</asp:DropDownList>
					<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="officer_card_address_subICT"
						ErrorMessage="กรุณาระบุแขวง/ตำบล" InitialValue="0" ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
				</ContentTemplate>
				<Triggers>
					<asp:AsyncPostBackTrigger ControlID="OFFICER_CARD_ADDRESS_DISTRICT" EventName="SelectedIndexChanged" />
				</Triggers>
			</asp:UpdatePanel>
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			รหัสไปรษณีย์ *:
		</td>
		<td>
			<asp:UpdatePanel ID="UpdatePanel3" runat="server">
				<ContentTemplate>
					<asp:DropDownList ID="OFFICER_CARD_ADDRESS_POSTCODE" runat="server" AutoPostBack="True">
					</asp:DropDownList>
					<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="OFFICER_CARD_ADDRESS_POSTCODE"
						ErrorMessage="กรุณาระบุรหัสไปรษณีย์" InitialValue="0" ValidationGroup="Reg1">*</asp:RequiredFieldValidator>
				</ContentTemplate>
				<Triggers>
					<asp:AsyncPostBackTrigger ControlID="officer_card_address_subICT" EventName="SelectedIndexChanged" />
				</Triggers>
			</asp:UpdatePanel>
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr>
		<td colspan="4">
			<hr />
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			หมายเลขโทรศัพท์<br />
			เพื่อให้ในการติดต่อ :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_MAIL_PHONE" runat="server"></asp:TextBox>
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			Email :
		</td>
		<td>
			<asp:TextBox ID="OFFICER_MAIL_EMAIL" runat="server" Width="260px"></asp:TextBox>
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			สถานะ
		</td>
		<td>
			<asp:DropDownList ID="ddlStatus" runat="server">
				<asp:ListItem Value="NM">สถานภาพปกติ</asp:ListItem>
				<asp:ListItem Value="CE">สถานภาพโมฆะ</asp:ListItem>
			</asp:DropDownList>
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr runat="server" id="trPWD1">
		<td bgcolor="#E0E0E0">
			รหัสผ่านใหม่:
		</td>
		<td>
			<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr runat="server" id="trPWD2">
		<td bgcolor="#E0E0E0">
			รหัสผ่านใหม่(ยืนยัน):
		</td>
		<td>
			<asp:TextBox ID="txtConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
			<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtConfirmPassword"
				ControlToValidate="txtPassword" ErrorMessage="กรุณาระบุรหัสผ่านใหม่ให้เหมือนก้น"
				ValidationGroup="Reg1">*</asp:CompareValidator>
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	<tr>
		<td bgcolor="#E0E0E0">
			หมายเหตุ:
		</td>
		<td colspan="3">
			<asp:TextBox ID="OFFICER_REMARK" runat="server" Width="350px" MaxLength="255"></asp:TextBox>
		</td>
	</tr>
	<tr>
		<td colspan="4" style="text-align: right">
			<asp:Button ID="btnSave" runat="server" Text="บันทึก" Width="70px" ValidationGroup="Reg1" />
			&nbsp;<asp:Button ID="btnCancel" runat="server" Text="ยกเลิก" Width="70px" />
		&nbsp;<asp:Button ID="btnAuthorizeSetting" runat="server" 
                Text="ตั้งค่าสิทธิ์การใช้งาน" Width="140px" />
		</td>
	</tr>
	<tr>
		<td colspan="4">
			<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Reg1" />
		</td>
	</tr>
	<tr>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
</table>
